<template>
  <div id="community">
    <el-table :data="detail.list" style="width: 100%">
      <el-table-column type="index" label="序号"/><br>
      <el-table-column prop="id" v-if="false" /><br>
      <el-table-column prop="name" label="社区名" /><br>
      <el-table-column prop="address" label="社区地址" /><br>
      <el-table-column prop="phone" label="社区电话" /><br>
    </el-table>
    <el-pagination  v-if="this.detail.total > 5"
      v-model:currentPage="detail.pageNum"
      v-model:page-size="detail.pageSize"
      :total="detail.total"
      :page-sizes="[5, 10]"
      :small="small"
      :background="background"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    ></el-pagination>
  </div>
</template>
    
<script>
export default {
  name: "Community",
  props: {
    list: {
      type: Object,
    },
  },
  data() {
    return {
      detail: [
        {
          list: [],
          total: 0,
          pageNum: 0,
          pageSize: 0,
        },
      ],
      user: {},
    };
  },
  methods: {
    handleSizeChange(size) {
      this.detail.pageSize = size;
      this.mount();
    },
    handleCurrentChange(num) {
      this.pageNum = num;
      this.mount();
    },
    mount() {
      this.$axios({
        method: "post",
        url: "http://localhost:8080/nav/tylir/communityone",
        data:
          this.$qs.stringify(this.user) +
          "&" +
          this.$qs.stringify({
            pageSize: this.detail.pageSize,
            pageNum: this.detail.pageNum,
          }),
      }).then((res) => {
        console.log(res.data);
        this.project2 = res.data;
        if (res.data.code == 1) {
          this.detail.list = res.data.data.list;
          this.detail.pageSize = res.data.data.pageSize;
          this.detail.pageNum = res.data.data.pageNum;
          this.detail.total = res.data.data.total;
        } else {
          console.log("error");
        }
      });
    },
  },
  mounted() {
    this.user = this.$store.state.user;
    this.mount();
  }
}
</script>

<style scoped>
</style>